﻿
@{
    Layout = null;
}

<div>
    <div class="col-3 pr-0" style="display: none">
        <label id="EditTextContent-Domain">@ViewData["Domain"]</label>
        <label id="EditTextContent-DomainId">@ViewData["DomainId"]</label>
        <label id="EditTextContent-Parent-ModalID">@ViewData["ModalID"]</label>
    </div>
    <div class="input-group">
        <div class="col-12 pr-0 pl-0">
            <span class="input-group-text font-rfs border-radius-noright">文本内容：</span>
        </div>
    </div>
    <div class="input-group">
        <div class="col-12 pr-0 pl-0" style="height:40vh;">
            <textarea id="EditTextContent-Content" class="form-control font-rfs border-radius-noleft" style="height:100%;"></textarea>
        </div>
    </div>
</div>
<div class="text-right" style="padding-top: 5px;">
    <button id="EditTextContent-confirm" type="button" class="btn btn-primary font-rfs">保存</button>
    <button id="EditTextContent-cancel" type="button" class="btn btn-info font-rfs">取消</button>
</div>

<script>

    $(document).ready(function () {
        $.post("/Common/GetTextContent", {
            Domain: $("#EditTextContent-Domain").html(),
            DomainId: $("#EditTextContent-DomainId").html()
        }, function (data) {
            $("#EditTextContent-Content").val(data);
        });
    });

    $("#EditTextContent-cancel").click(function (event) {
        var modalID = $("#EditTextContent-Parent-ModalID").html();
        $("#" + modalID).modal('hide');
    });

    $("#EditTextContent-confirm").click(function () {
        if ($.trim($("#EditTextContent-Content").val()).length == 0) {
            $("#EditTextContent-cancel").click();
            return;
        } 

        $.post("/Common/SaveTextContent", {
            Domain: $("#EditTextContent-Domain").html(),
            DomainId: $("#EditTextContent-DomainId").html(),
            Content: document.getElementById('EditTextContent-Content').value
        }, function (data) {
            alert(data);
            $("#EditTextContent-cancel").click();
        });
    });

</script>
